package com.ruix.app.mapper;

import com.ruix.app.model.LessonPostMember;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;

/**
 * Created by hadexs on 2017/5/23.
 */

public class LessonPostMemberMapper implements ApiMapper<ArrayList<LessonPostMember>>{

    @Override
    public ArrayList<LessonPostMember> transform(JSONObject response) {
        ArrayList<LessonPostMember> mebers = null;
        if (response != null){
            JSONObject data =  response.optJSONObject("data");
           JSONArray list =  data.optJSONArray("list");
            if (list != null && list.length() > 0){
                mebers = new ArrayList();
                for (int i = 0; i <list.length() ; i++) {
                    LessonPostMember member = new  LessonPostMember().parse(list.optJSONObject(i));
                    mebers.add(member);
                }
            }

        }

        return mebers;
    }
}
